<template>
  <div class="myDialog" v-show="show">
    <div class="myDialog-bg" v-if="cfg['bg']"></div>
    <div class="myDialog-box"
         :style="{width:cfg['width']+'px',height:cfg['height']+'px',marginLeft:-cfg['width']/2+'px',marginTop:-cfg['height']/2+'px'}">
      <div class="myDialog-header noBlueBg" v-if="cfg['title']">
        <div class="myDialog-title">{{cfg['title']}}</div>
        <span class="myDialog-close" @click="close(0)" v-if="cfg['closeShow']">×</span>
      </div>
      <div class="myDialog-cont">
        <div v-html="cfg['cont']"></div>
        <slot></slot>
      </div>
      <!-- <div class="myDialog-cont">

      </div> -->

      <div class="myDialog-footer" v-if="cfg['footerShow']">
        <!-- <el-button size="mini" type="primary" @click="close(1)">保存</el-button> -->
        <el-button size="mini" @click="close(0)">关闭</el-button>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    name: "Yswlog",
    data() {
      return {
        show: false,
      };
    },
    watch: {

    },
    props: {
      cfg: {
        type: Object,
        default: {}
      }

    },
    mounted() {

    },
    beforeDestroy() {
      this.show = false;
    },
    computed: {},
    methods: {
      close(isSubmit) {
        console.log("12312"+isSubmit);
        if (isSubmit) {
          if (typeof this.cfg['submit'] === 'function') {
            this.cfg['submit'](() => {
              this.show = false;
            });
          }
        } else {
          this.show = false;
        }
      },
            
    }
  }
</script>

<style scoped>
  .myDialog {
    position: fixed;
    width: 100vw;
    height: 100vh;
    top: 0;
    left: 0;
    z-index: 1000;
  }

  .myDialog-bg {
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, .3);
  }

  .myDialog-box {
    position: absolute;
    top: 50%;
    left: 50%;
    background-color: #fff;
    border-radius: 2px;
    border: 1px solid #d4d3d4;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
  }

  .myDialog-header {
    position: relative;
    height: 40px;
    line-height: 40px;
    padding: 0 15px;
    border-bottom: 1px solid #ddd;
    color: #666;
    font-size: 14px;
    /*font-weight: 600;*/
    background-color: #f0f0f0;
    cursor: default;
  }

  .myDialog-close {
    position: absolute;
    right: 10px;
    top: 1px;
    font-size: 20px;
    opacity: .6;
    cursor: pointer;
  }


  .myDialog-close:hover {
    opacity: 1;
  }

  .myDialog-cont {
    padding: 10px;
    flex: 1;
    overflow-y: auto;
  }

  .myDialog-footer {
    padding: 0 15px;
    height: 50px;
    line-height: 50px;
    text-align: right;
  }
</style>
